package com.lu.pojo.oop.classes;

/**
 * @author luzhenfang
 * @date 2020 2 24
 * @description 重写 equals 方法
 */
public class Order {
    private int orderId;
    private String orderName;
    @Override
    public boolean equals(Object obj) {
        if(obj instanceof Order){
            Order other =(Order)obj;
            return this.orderId == other.orderId&&this.orderName.equals(other.orderName);
        }
        return false;
    }
    public Order() {
    }
    public Order(int orderId, String orderName) {
        this.orderId = orderId;
        this.orderName = orderName;
    }
    public int getOrderId() {
        return orderId;
    }
    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }
    public String getOrderName() {
        return orderName;
    }
    public void setOrderName(String orderName) {
        this.orderName = orderName;
    }

    public static void main(String[] args) {
        Order order1 = new Order(123,"test");
        Order order2 = new Order(123,"test");
        System.out.println(order1.equals(order2));
    }

}
